import request from "@/request";
import { User } from "../user/service";

const myService = {
  getMyProject: (id: string) => {
    return request.get(`/api/project/user/${id}`);
  },

  getMyInProgressPlan: (id: string) => {
    return request.get(`/api/plan/getMyPlan`, {
      params: {
        id: id,
        state: "1",
      },
    });
  },

  getMySuspendPlan: (id: string) => {
    return request.get(`/api/plan/getMyPlan`, {
      params: {
        id: id,
        state: "0",
      },
    });
  },

  deleteItem: (id: string) => {
    return request.delete(`/api/plan/${id}`);
  },

  getAllUser: () => {
    return request.get<User[]>("/api/user/list");
  },

  getMyProjectPlans: (data: any) => {
    return request.get("/api/plan/getByProjectIdAndUserId", { params: data });
  },

  savePlan: (data: any) => {
    return request.put("/api/plan", data);
  },

  newPlan: (data: any) => {
    return request.post("/api/plan", data);
  },
};

export default myService;
